/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.codingbros.eldercare;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author niebje
 */
@Entity
@Table(name = "events")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Events.findAll", query = "SELECT e FROM Events e"),
    @NamedQuery(name = "Events.findById", query = "SELECT e FROM Events e WHERE e.id = :id"),
    @NamedQuery(name = "Events.findByTitle", query = "SELECT e FROM Events e WHERE e.title = :title"),
    @NamedQuery(name = "Events.findBySubtitle", query = "SELECT e FROM Events e WHERE e.subtitle = :subtitle"),
    @NamedQuery(name = "Events.findByDate", query = "SELECT e FROM Events e WHERE e.date = :date"),
    @NamedQuery(name = "Events.findByCreated", query = "SELECT e FROM Events e WHERE e.created = :created"),
    @NamedQuery(name = "Events.findByRequiresSignup", query = "SELECT e FROM Events e WHERE e.requiresSignup = :requiresSignup")})
public class Events implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Long id;
    @Size(max = 255)
    @Column(name = "title")
    private String title;
    @Size(max = 255)
    @Column(name = "subtitle")
    private String subtitle;
    @Lob
    @Size(max = 65535)
    @Column(name = "body")
    private String body;
    @Column(name = "date")
    @Temporal(TemporalType.DATE)
    private Date date;
    @Basic(optional = false)
    @NotNull
    @Column(name = "created")
    @Temporal(TemporalType.TIMESTAMP)
    private Date created;
    @Column(name = "requires_signup")
    private Boolean requiresSignup;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "eventsId")
    private Collection<ImagesEvents> imagesEventsCollection;

    public Events() {
    }

    public Events(Long id) {
        this.id = id;
    }

    public Events(Long id, Date created) {
        this.id = id;
        this.created = created;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getSubtitle() {
        return subtitle;
    }

    public void setSubtitle(String subtitle) {
        this.subtitle = subtitle;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Boolean getRequiresSignup() {
        return requiresSignup;
    }

    public void setRequiresSignup(Boolean requiresSignup) {
        this.requiresSignup = requiresSignup;
    }

    @XmlTransient
    public Collection<ImagesEvents> getImagesEventsCollection() {
        return imagesEventsCollection;
    }

    public void setImagesEventsCollection(Collection<ImagesEvents> imagesEventsCollection) {
        this.imagesEventsCollection = imagesEventsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Events)) {
            return false;
        }
        Events other = (Events) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.codingbros.eldercare.Events[ id=" + id + " ]";
    }
    
}
